package ldkxingzhe.ldkxingzhedemo.intent;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;

/**
 * Created by ke on 15-9-18.
 */
public class IntentDemoActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FrameLayout layout = new FrameLayout(this);
        Button button = new Button(this);
        button.setText("click me ACTION_SEND");
        layout.addView(button);
        setContentView(layout);

        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "This is Message");

        startActivity(new Intent().createChooser(intent,"This is the chooser's title"));
    }
}
